package us.mooresr.aircraftscheduling.server.handler;

import us.mooresr.aircraftscheduling.server.DAO;
import us.mooresr.aircraftscheduling.shared.action.GetUserDetailAction;
import us.mooresr.aircraftscheduling.shared.action.GetUserDetailResult;
import us.mooresr.aircraftscheduling.shared.model.User;
import us.mooresr.aircraftscheduling.shared.model.UserDetail;

import com.gwtplatform.dispatch.server.ExecutionContext;
import com.gwtplatform.dispatch.server.actionhandler.ActionHandler;
import com.gwtplatform.dispatch.shared.ActionException;

public class GetUserDetailHandler  implements 
	ActionHandler<GetUserDetailAction, GetUserDetailResult> {

	@Override
	public GetUserDetailResult execute(GetUserDetailAction arg0,
			ExecutionContext arg1) throws ActionException {
		DAO dao = new DAO();
		
		Long userId = arg0.getUserId();
		
		UserDetail userDetail = dao.ofy().get(UserDetail.class, userId);
		
		return new GetUserDetailResult( userDetail);
		
	}

	@Override
	public Class<GetUserDetailAction> getActionType() {
		return GetUserDetailAction.class;
	}

	@Override
	public void undo(GetUserDetailAction arg0, GetUserDetailResult arg1,
			ExecutionContext arg2) throws ActionException {
		
		
	}

}
